func TurnAround {
    turnLeft()
    turnLeft()
}

func collectToggle {
    if isOnGem {
        collectGem()
    } else if isOnClosedSwitch {
        toggleSwitch()
    }
}

func moveActTurn {
    moveForward()
    collectToggle()
    turnAround()
}

func solveHalf {
    moveActTurn()
    moveForward()
    turnLeft()
    moveActTurn()
}

func solveOtherHalf {
    moveActTurn()
    moveForward()
    turnRight()
    moveForward()
    collectToggle()
}

orangePortal.isActive = false
turnRight()
moveForward()
moveForward()
solveHalf()
orangePortal.isActive = true
 ​moveForward()
orangePortal.isActive = false
solveHalf()
moveForward()
solveOtherHalf()
moveForward()
greenPortal.isActive = false
moveForward()
solveHalf()
greenPortal.isActive = true
moveForward()
greenPortal.isActive = false
solveHalf()
moveForward()
solveOtherHalf()
